package com.example.controlexercise;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

public class listItemAdapter extends ArrayAdapter<getItem> {

    private int resource;
    public listItemAdapter(Context context, int resource, List<getItem> list){
        super(context,resource,list);
        this.resource = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        getItem item = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(R.layout.listlayout,parent,false);
        ImageView imageView= view.findViewById(R.id.itemIcon);
        TextView textView = view.findViewById(R.id.itemText);
        imageView.setBackgroundResource(item.getIcon());
        textView.setText(item.getContent());
        return view;
    }
}
